package com.mobile.manager.service.impl;

import com.mobile.manager.dao.IApkDao;
import com.mobile.manager.pojo.Apk;
import com.mobile.manager.service.IApkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zhangdi on 16/6/12.
 */
@Service("apkService")
public class ApkServiceImpl implements IApkService{
    @Resource
    private IApkDao apkDao;

    @Override
    public Apk getApkById(int id) {
        return this.apkDao.getApkById(id);
    }

    @Override
    public List<Apk> searchApk(Apk apk) {

        if(apk.getPackage_env().equals("1")){
            apk.setPackage_env("稳定环境");
        }
        if(apk.getPackage_env().equals("2")){
            apk.setPackage_env("A环境");
        }
        if(apk.getPackage_env().equals("3")){
            apk.setPackage_env("B环境");
        }
        if(apk.getPackage_env().equals("4")){
            apk.setPackage_env("C环境");
        }
        if(apk.getPackage_env().equals("5")){
            apk.setPackage_env("沙箱环境");
        }
        if(apk.getPackage_env().equals("6")){
            apk.setPackage_env("线上环境");
        }
        if(apk.getPackage_env().equals("7")){
            apk.setPackage_env("接口环境");
        }
        if(apk.getPackage_env().equals("8")){
            apk.setPackage_env("性能环境");
        }
        if(apk.getPackage_os().equals("1")){
            apk.setPackage_os("Android");
        }
        if(apk.getPackage_os().equals("2")){
            apk.setPackage_os("IOS");
        }

        //category 转换
        if(apk.getPackage_category().equals("1")){
            apk.setPackage_category("到家用户端");
        }
        if(apk.getPackage_category().equals("2")){
            apk.setPackage_category("家政商家端");
        }
        if(apk.getPackage_category().equals("3")){
            apk.setPackage_category("丽人商家端");
        }
        if(apk.getPackage_category().equals("4")){
            apk.setPackage_category("速运司机端");
        }
        if(apk.getPackage_category().equals("5")){
            apk.setPackage_category("学艺商家端");
        }
        if(apk.getPackage_category().equals("6")){
            apk.setPackage_category("速运用户端");
        }
        if(apk.getPackage_category().equals("7")){
            apk.setPackage_category("家政经纪人端");
        }
        if(apk.getPackage_category().equals("8")){
            apk.setPackage_category("保姆商家端");
        }
        return this.apkDao.searchApk(apk);
    }

    @Override
    public int addApk(Apk apk) {
        return this.apkDao.insertApk(apk);
    }

    @Override
    public String getCountOfApkByOS(Apk apk) {
        return this.apkDao.getCountOfApkByOS(apk);
    }


}
